import wx
		
def random_color(alpha_range=None):
	alpha=random.randint(*alpha_range) if alpha_range else wx.ALPHA_OPAQUE
	return wx.Colour(random.randint(0,255),random.randint(0,255),random.randint(0,255),alpha)

def random_pen(alpha_range=None):
	return wx.Pen(random_color(alpha_range))
	
def random_brush(alpha_range=None):
	return wx.Brush(random_color(alpha_range))
	
def add_transparency(color,alpha):
	r,g,b=color.Red(),color.Green(),color.Blue()
	return wx.Colour(r,g,b,alpha)
	
def brighten(color,how_much):
	assert 0<=how_much<=1
	r,g,b=[x+(255-x)*how_much for x in (color.Red(),color.Green(),color.Blue())]
	return wx.Colour(r,g,b,color.Alpha())
	
def interpolate(color1,color2,how_much=.5):
	assert 0<=how_much<=1
	r1,g1,b1=color1.Red(),color1.Green(),color1.Blue()
	r2,g2,b2=color2.Red(),color2.Green(),color2.Blue()
	
	return wx.Colour(r1+how_much*(r2-r1),g1+how_much*(g2-g1), b1+how_much*(b2-b1))

def Gray(b):
	return wx.Colour(b,b,b)